package com.jiazhong.cloud.seata.stock.controller;

import com.jiazhong.cloud.seata.stock.bean.Stock;
import com.jiazhong.cloud.seata.stock.service.StockService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/stock")
public class StockController {
    @Resource
    private StockService stockService;

    @RequestMapping("/update/{gid}/{number}")
    public String update(@PathVariable("gid") String gid,@PathVariable("number") int number) {
        Stock stock = new Stock();
        stock.setGid(gid);
        stock.setNumber(number);
        return stockService.update(stock) == 0 ? "失败" : "成功";
    }
}
